<?php
    session_start();
?>

<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
            <link rel="stylesheet" href="styles/layout.css" type="text/css"/>
            <link rel="stylesheet" href="styles/computer.css" type="text/css"/>
            <script type="text/javascript" src="scripts/computer.js"></script>
    </head>
    <body>
        <?php require 'header.html';
        ?>
        
<div id="container">
<div class="wrapper">
<div id="content">
<div id="order">
        <?php
        // put your code here
            echo "Welcome customer ".$_SESSION["firstName"]." ".$_SESSION["lastName"];
//            echo session_id();
            
            $con = mysql_connect("localhost", "zhouzhao", "19831022");
            if(!$con){
                die("could not connect to DB: ".mysql_error());
            }
            
            mysql_select_db("cloudcom", $con);
            
            $result = mysql_query("select * from orders where customerID = ".$_SESSION["customerID"]);
        ?>
    <form method="post" name="order" action="showItem.php">
        <table border="1" id="orderTable">
            <tr>
                <th>Order date</th>
                <th>Total price</th>
                <th>Credit card number</th>
                <th>Credit card name</th>
                <th>Credit card expiration date</th>
                <th>Select</th>
            </tr>
            <?php
                while($row = mysql_fetch_assoc($result)){
                    echo "<tr>";
                    echo "<td>".$row["orderDate"]."</td>";
                    echo "<td>".$row["totalPrice"]."</td>";
                    echo "<td>".$row["cardNum"]."</td>";
                    echo "<td>".$row["cardName"]."</td>";
                    echo "<td>".$row["expDate"]."</td>";
                    echo "<td><input type='radio' name='orderID' value='".$row["orderID"]."'/></td>";
                }
                mysql_close($con);
            ?>
        </table>
        <input type="submit" value="Order Detail" class="buttonStyle" onmouseover="changeOn(this)" onmouseout="changeOff(this)"/>
        
    </form>
    <?php
    if(isset($_SESSION["customerID"])){
    ?>
    <form method="post" name="logout" action="logout.php">
        <input type="submit" value="Logout" class="logoutStyle" onmouseover="changeOn(this)" onmouseout="changeOff(this)"/>
    </form>
    <?php
    }
    ?>    
</div>	
</div>
<br class="clear" />
</div>
</div>
        <?php        require 'tail.html';
        ?>
        
    </body>
</html>
